home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / misc / math / lifemake.cpt / LifeMaker Demo.rsrc / LIF3_4459_Digital < prev    next >
Encoding:
Text File  |  1991-07-16  |  1.3 KB  |  37 lines

  1. RULE Digital
  2.    VAR noWires, high
  3. BEGIN
  4.    IF cell[0] THEN                                 (* does cell contain wire? *)
  5.       noWires := cell[0] + cw[0] + ccw[0] + opp[0] (* yes, find number of wires *)
  6.       IF noWires = 1 THEN
  7.          high := opp[1] OR cw[1] OR ccw[1]
  8.       ELSIF noWires = 2 THEN                       (* move signal along wire *)
  9.          IF opp[0] THEN
  10.             high := opp[1]
  11.          ELSIF cw[0] THEN
  12.             IF opp[1] THEN                         (* check for NOT gate *)
  13.                high := cw[1] XOR 1                 (* xor = not for single bits *)
  14.             ELSE
  15.                high := cw[1]
  16.             END
  17.          ELSIF ccw[0] THEN
  18.             IF opp[1] THEN                 
  19.                high := ccw[1] XOR 1         
  20.             ELSE
  21.                high := ccw[1]
  22.             END
  23.          END
  24.       ELSIF noWires = 3 THEN                       (* handle gates *)  
  25.          IF (opp = 2) OR (cw = 2) OR (ccw = 2) THEN   
  26.             high := (opp <> 1) AND (cw <> 1) AND (ccw <> 1)
  27.          ELSE
  28.             high := (opp = 3) OR (cw = 3) OR (ccw = 3)
  29.          END
  30.       ELSIF noWires = 4 THEN
  31.          high := opp[1]                           (* handle cross-over *)
  32.       END
  33.    ELSE
  34.       high := cell[1]                             (* signals off wire stay put *)
  35.    END
  36.    RETURN cell[0] + 2*high
  37. END